<?php
session_start();
include "connect.php";

//Feedback Details
$currentDate = date("y.m.d");
$feedbackType = $_POST['feedbackType'];
$feedbackMessage = $_POST['feedbackMessage'];
$customerName = $_POST['customerName'];

//Echo post details TESTING ONLY
//echo $feedbackMessage;

mysql_query("INSERT INTO feedback(

date,
customer,
type,
feedback,
status
) 

VALUES(

'$currentDate',
'$customerName',
'$feedbackType',
'$feedbackMessage',
'New'
) 

"); 


// multiple recipients
$to  = "sales@24-7saddles.com";
$from = "noreply@24-7saddles.com";

// subject
$subject = 'New Feedback Received';

// message
$message = '
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Customer Feedback</title>
<style type="text/css">
#emailContainer {
	height: auto;
	width: 300px;
	margin-right: auto;
	margin-left: auto;
	padding: 10px;
}

#emailContainer p {
	width: 300px;
	text-align: left;
	font-family: "Century Gothic";
	font-size: 14px;
	float: left;
	height: auto;
	margin-bottom: 20;
}

#emailContainer a {
	font-family: "Century Gothic";
	font-size: 16px;
	color: #FFF;
	background-color: #003;
	padding: 10px;
	text-decoration: none;
	float: left;
	margin-top: 10px;
	width: 140px;
	margin-right: auto;
	margin-left: auto;
}

#emailContainer h1 {
	font-family: "Century Gothic";
	font-size: 18px;
	color: #003;
	font-weight: normal;
}
</style>
</head>

<body>

<div id="emailContainer">
 
    <h2>New feedback recieved</h2>
    
  <p>
  <b>Feedback:</b> '.$feedbackType.'
  <br />
  <b>From:</b> '.$customerName.'
  <br />
  <b>Message:</b> '.$feedbackMessage.'
  </p>
  
  <p>
  Log in below to review feedback...
  </p>
    
    <a href="http://24-7saddles.com/adminFiles/index.php">Log in</a>

	</div>


</body>
</html>
';

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
//$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: '.$from.' <'.$from.'>' . "\r\n";
//$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
//$headers .= 'Bcc: sean.richardson@hotmail.co.uk' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);


header('Location: index.php')

?>